import 'package:flutter/material.dart';

class NeumorphicTheme {
  static BoxDecoration surfaceDecoration({
    required Color baseColor,
    bool isPressed = false,
    BorderRadius? borderRadius,
  }) {
    return BoxDecoration(
      color: baseColor,
      borderRadius: borderRadius ?? BorderRadius.circular(16),
      boxShadow: [
        BoxShadow(
          color: Colors.white.withOpacity(0.8),
          offset: isPressed ? const Offset(-2, -2) : const Offset(-4, -4),
          blurRadius: isPressed ? 4 : 8,
          spreadRadius: 0,
        ),
        BoxShadow(
          color: Colors.black.withOpacity(isPressed ? 0.2 : 0.1),
          offset: isPressed ? const Offset(2, 2) : const Offset(4, 4),
          blurRadius: isPressed ? 4 : 8,
          spreadRadius: 0,
        ),
      ],
    );
  }

  static BoxDecoration insetDecoration({
    required Color baseColor,
    BorderRadius? borderRadius,
  }) {
    final darkerColor =
        HSLColor.fromColor(baseColor)
            .withLightness(
              (HSLColor.fromColor(baseColor).lightness - 0.1).clamp(0.0, 1.0),
            )
            .toColor();

    return BoxDecoration(
      borderRadius: borderRadius ?? BorderRadius.circular(16),
      gradient: LinearGradient(
        begin: Alignment.topLeft,
        end: Alignment.bottomRight,
        colors: [darkerColor, baseColor],
      ),
      boxShadow: [
        BoxShadow(
          color: Colors.black.withOpacity(0.2),
          offset: const Offset(-2, -2),
          blurRadius: 4,
          spreadRadius: 0,
        ),
        BoxShadow(
          color: Colors.white.withOpacity(0.3),
          offset: const Offset(2, 2),
          blurRadius: 4,
          spreadRadius: 0,
        ),
      ],
    );
  }

  static BoxDecoration gradientSurfaceDecoration({
    required Gradient gradient,
    BorderRadius? borderRadius,
  }) {
    return BoxDecoration(
      gradient: gradient,
      borderRadius: borderRadius ?? BorderRadius.circular(16),
      boxShadow: [
        BoxShadow(
          color: Colors.white.withOpacity(0.8),
          offset: const Offset(-4, -4),
          blurRadius: 8,
        ),
        BoxShadow(
          color: Colors.black.withOpacity(0.1),
          offset: const Offset(4, 4),
          blurRadius: 8,
        ),
      ],
    );
  }
}
